package com.clean.notification.device;

import android.os.Build;
import android.os.LocaleList;
import android.text.TextUtils;

import java.util.Locale;

public class CountryManagerPhone {

    private static String sMatchedMccCountryName = "none";
    private static String ipCountry;
    private String mCountry;
    private static volatile CountryManagerPhone instance;
    private static String newSystemCountry = "";
    private static String newSystemLanguage = "";
    private static int mccCode = -1;

    private CountryManagerPhone() {
    }

    public static CountryManagerPhone getInstance() {
        if (instance == null) {
            instance = new CountryManagerPhone();
        }
        return instance;
    }

    public String getNewSystemLanguage() {
        if (!TextUtils.isEmpty(newSystemLanguage)) {
            return newSystemLanguage;
        }
        newSystemLanguage = Locale.getDefault().getLanguage();
        if (TextUtils.isEmpty(newSystemLanguage)) {
            newSystemLanguage = "unknown";
        }
        return newSystemLanguage;
    }

    public String getNewSystemCountry() {
        if (!TextUtils.isEmpty(newSystemCountry)) {
            return newSystemCountry;
        }
        newSystemCountry = Locale.getDefault().getCountry();
        if (TextUtils.isEmpty(newSystemCountry)) {
            newSystemCountry = "unknown";
        }
        return newSystemCountry;
    }

    public String getCountry() {
        if (!TextUtils.isEmpty(mCountry)) {
            return mCountry;
        }
        mCountry = getSystemLanguage();

        return mCountry;
    }


    public String getSystemLanguage() {
        Locale locale;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            locale = LocaleList.getDefault().get(0);
        } else {
            locale = Locale.getDefault();
        }
        return locale.getLanguage();
    }

    public int getMcc() {
        return -1;
    }


}
